<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');
/**
 * 我的收藏
 * */
class Collect_model extends MY_Model
{
    private $table = 'collect';
    private $models=['type_model'];  
	public function __construct()
	{
		parent::__construct($this->table,$this->models);
	
	}

	
	/**
	 * 获取收藏的店铺
	 * */
	public function getcollect_company($userId=0,$limit,$offset){
	    $select='company.companyId,name,concat("'.IMAGEHOST.'",company.poster) as poster,trade.typeName as tradeName,judge,consume';
	    
	    $this->db->join('company','collect.listId=company.companyId');
	    $this->db->join('type as trade','trade.typeId=company.tradeId','left');
	    $where=['collect.userId'=>$userId,'collect.typeFlag'=>4];
	    $dbArray['page']=['limit'=>$limit,'offset'=>$offset];
	    return $this->getWhere($where,$select,$dbArray);	    
	}
	
	/**
	 * 获取收藏的项目
	 * */
	public function getcollect_project($userId=0,$limit,$offset){
	    $select='projectId,title,concat("'.IMAGEHOST.'" ,poster)as poster,judge,price,sales';
	    $this->db->join('project','collect.listId=project.projectId');
	    $where=['collect.userId'=>$userId,'collect.typeFlag'=>5];
	    $dbArray['page']=['limit'=>$limit,'offset'=>$offset];
	    return $this->getWhere($where,$select,$dbArray);	
	}
	
	/**
	 * 获取收藏的技师
	 * */
	public function getcollect_technician($userId=0,$limit,$offset){
	    $select='technicianId,realName,judge,job.typeName as jobName,concat("'.IMAGEHOST.'",poster) as poster,giftNum,
                sevriceNo,tags,skill,workStatus';
	    
	    $this->db->join('technician','collect.listId=technician.technicianId');
	    $this->db->join('type as job','job.typeId=technician.jobId','left');
	    $where=['collect.userId'=>$userId,'collect.typeFlag'=>6];
	    $dbArray['page']=['limit'=>$limit,'offset'=>$offset];
	    $technician=$this->getWhere($where,$select,$dbArray);
	    foreach ($technician as $key=>$val){
	        $technician[$key]['skill']=$this->type_model->getSkill(explode('|', $val['skill']));
	    }
	    return $technician;
	}
	
}
?>